import { _decorator, Component, Node,AudioSource } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AudioManager')
export class AudioManager extends Component {

    @property(AudioSource) 
    audioSource: AudioSource = null!;
    
    start() {
        this.audioSource = this.node.getComponent(AudioSource)!;
    }


    update(deltaTime: number) {
        
    }

    playMusic(){
        this.audioSource.loop = true;
        if (!this.audioSource.playing) {
            this.audioSource.play();
        }
    }

    stopMusic(){
        this.audioSource.pause();
    }
}

